import React from 'react';
import './map.scss';
import { api } from 'js/api/api';
import { browserHistory } from 'react-router';
import { userData } from 'js/core/userData';
import Progress from 'views/component/progress/progress';
import Button from 'views/component/button/button';

class Main extends React.Component {
    changeMap = (mapId) => {
        // api('changeMap', { mapType: mapType }, (err, data) => {
        //     if (err === 0) {
        //         if (data && data.log) {
        //             window.eventHandle.emit('log', data.log);
        //         }
        //         this.setState({})
        //         browserHistory.push(mapName)
        //     }
        // })

        api('enterAdventureMap', { mapId: mapId }, (err, data) => {
            if (err === 0) {
                if (data && data.log) {
                    window.eventHandle.emit('log', data.log);
                }
                this.setState({})
                browserHistory.push('/maze')
            }
        })
    }
    render() {
        return (
            <div id="map" className="flex-col">
                <div className="map-content flex-g-1">
                    <div className="map-button map-180001" onClick={() => this.changeMap(180001)}>
                        <div className="name">黑暗森林</div>
                        <div className="info">1-5级</div>
                    </div>
                    <div className="map-button map-180002" onClick={() => this.changeMap(180002)}>
                        <div className="name">埋骨之地</div>
                        <div className="info">6-10级</div>
                    </div>
                </div>
                <div className="bottom flex-center">
                    <div className="home-button home" onClick={() => this.changeMap(3, '/town')}>返回城镇</div>
                </div>

            </div>
        )
    }
}

export default Main;